<template>
    <div>
      <zh-form ref="formRef" :md="24" :lg="24" :xl="24"  :model="fileAppReadInfo" :rules="rules" labelWidth="120">
        <zh-form-input prop="fileClassCode" label="文件分类编码"  v-model="fileAppReadInfo.fileClassCode"
                       disabled></zh-form-input>
                       
        <zh-form-input prop="classTitle" label="分类标题"  v-model="fileAppReadInfo.classTitle"
                       disabled></zh-form-input>
        <zh-form-select
            prop="appId"
            :lazy="true"
            label="我的应用"
            v-model="fileAppReadInfo.appId"
            :fieldNames="{ label: 'appName', value: 'appId' }"
            funcCode="application0012"
            searchField="appName"
        ></zh-form-select>
        <zh-form-select
            prop="secrecyLevel"
            label="保密级别"
            :options="state.dictData.secrecyLevel"
            v-model="fileAppReadInfo.secrecyLevel"
        ></zh-form-select>
        <zh-form-input type="date" prop="expireTime" label="到期时间"  v-model="fileAppReadInfo.expireTime"
                       :disabled="props.displayFlag"></zh-form-input>
      </zh-form>
    </div>
</template>

<script lang="ts" setup name="fileAppReadInfo">
import {FormInstance} from "element-plus";
import ZhForm from "@/components/zh-form/index.vue";

// ------------------变量区------------------------------
const props = defineProps({
  scrollHeight: {
    type: String,
    default: ''
  },
  displayFlag: {
    type: Boolean,
    default:false
  },
});
const formRef = ref<FormInstance>();
const fileAppReadInfo = ref<any>({
});

const rules = reactive({
  appId: [
    {
      required: true,
      message: '请选择需要授权的应用',
      trigger: 'blur',
    },
  ],
  expireTime: [
    {
      required: true,
      message: '请选择过期时间',
      trigger: 'blur',
    },
  ],
  secrecyLevel: [
    {
      required: true,
      message: '请选择保密级别',
      trigger: 'blur',
    },
  ]
});
const state = reactive({
  dictData:[]
});



//---------------------初始化---------------------
const params = {
  dictFields: 'secrecyLevel',
};
$api.common.getBatchDict.post(params).then((res) => {
  state.dictData = res.result;
});

//--------------------------定义调用方法--------------------------------------------------
function setInitData(info) {
  formRef.value?.resetFields();
  if (info) {
    fileAppReadInfo.value=info;
  }
}

//------------设置给父组件调用的数据/方法(组件)-----------
defineExpose({setInitData,fileAppReadInfo});
</script>
